from interface import admin_interface,user_interface

#1.解冻用户账户
def thawing_account():
    print('解冻用户')
    while True:
        thawing_name = input('请输入要解冻的账号:').strip()
        flag,msg=admin_interface.thawing_account_interface(thawing_name)
        if flag:
            print(msg)
            break
        else:
            print(msg)
            break


#2.冻结用户账户
def freeze_account():
    print('冻结用户')
    while True:
        freeze_name = input('请输入要冻结的账号:').strip()
        flag, msg = admin_interface.freeze_account_interface(freeze_name)
        if flag:
            print(msg)
            break
        else:
            print(msg)
            break

#3.提升用户额度
def increase_credit():
    print('提升用户额度')
    while True:
        name = input('请输入要提升额度的账号:').strip()
        credit=input('请输入要提升的金额:').strip()
        if credit.isdigit():
            credit=int(credit)
            flag,msg = admin_interface.increase_credit_interface(name, credit)
            if flag:
                print(msg)
                break
            else:
                print(msg)
                break

        else:
            print('金额请输入数字')
            break



#4.减少用户额度
def decrease_credit():
    print('降低用户额度')
    while True:
        name = input('请输入要降低额度的账号:').strip()
        credit = input('请输入要降低的金额:').strip()
        if credit.isdigit():
            credit = int(credit)
            flag, msg = admin_interface.decrease_credit_interface(name, credit)
            if flag:
                print(msg)
                break
            else:
                print(msg)
                break

        else:
            print('金额请输入数字')
            break



#5.重置用户的密码
def reset_password():
    print('重置用户密码')
    while True:
        name = input('请输入要重置用户的账号:').strip()
        pwd = input('请输入要重置的密码:').strip()
        flag, msg = admin_interface.reset_password_interface(name,pwd)
        if flag:
            print(msg)
            break
        else:
            print(msg)
            break




#6.添加用户
def add_user():
    print('添加新的用户')
    while True:
        name = input('请输入用户账号:').strip()
        pwd = input('请输入用户密码:').strip()
        conf_pwd=input('请再次输入用户密码:').strip()
        if pwd==conf_pwd:
            flag, msg = user_interface.register_interface(name,pwd)
            if flag:
                print(msg)
                break
            else:
                print(msg)
                break
        else:
            print('两次密码不一致，请重新输入')

